#include "race.h"
#include <iostream>
#include <cassert>

Race::Race(QDomNode& node) {
	
	QDomElement elem = node.namedItem("number").toElement();
	assert(!elem.isNull());
	m_number = static_cast<int>(elem.text());
		
	elem = node.namedItem("distance").toElement();
	assert(!elem.isNull());
	m_distance = static_cast<int>(elem.text());

	elem = node.namedItem("win").toElement();
	assert(!elem.isNull());
	m_win = static_cast<int>(elem.text());

	elem = node.namedItem("place").toElement();
	assert(!elem.isNull());
	m_place = static_cast<int>(elem.text());

	elem = node.namedItem("show").toElement();
	assert(!elem.isNull());
	m_show = static_cast<int>(elem.text());
}

void Race::print() const {
	std::cout << "Race " << m_number << std::endl
			  << "Distance: " << m_distance << " furlongs" << std::endl
			  << "Prize Money:" << std::endl
			  << "  Win: $" << m_win << std::endl
			  << "  Place: $" << m_place << std::endl
			  << "  Show: $" << m_show << std::endl << std::endl;
}
